package org.ns.framework.datasource.mybatis;

import org.aopalliance.intercept.MethodInvocation;
import org.apache.ibatis.session.ExecutorType;
import org.ns.framework.extension.aop.AopMethodInterceptor;
/**
 * Mybatis 事务代理
 * @author zhangxingyu
 *
 */
public class MybatisTransactionProxy implements AopMethodInterceptor {
	// org.springframework.transaction.annotation.Transactional
	@Override
	public Object invoke(MethodInvocation invocation) throws Throwable {
		TransactonManage transactonManage = TransactonManage.create(invocation.getMethod(), ExecutorType.REUSE, null);
		try {
			return invocation.proceed();
		} finally {
			transactonManage.close(invocation.getMethod());
		}
	}

}
